package com.cloudcross.ssp.common.consts;

import java.util.ArrayList;
import java.util.List;

import com.adinall.dsp.core.data.KeyValueBeanOld;

/**
 * 首页时间选择用枚举
 * 
 * @author 高万超
 * @version V1.0.0 $ 2017年6月21日 下午12:36:51
 */
public enum IndexDate {

    YESTERDAY(0, "昨天", 1),

    LAST3(1, "前３天", 3),

    LAST7(2, "前７天", 7),

    LAST30(3, "前３０天", 30);

    public final int code;
    public final String name;
    public final int day;

    IndexDate(int code, String name, int day) {
        this.code = code;
        this.name = name;
        this.day = day;
    }

    public static IndexDate search(int code) {

        for (IndexDate e : values()) {

            if (e.code == code) {
                return e;
            }
        }

        return YESTERDAY;
    }

    public static List<KeyValueBeanOld> list() {

        List<KeyValueBeanOld> data = new ArrayList<>();

        for (IndexDate e : values()) {
            data.add(new KeyValueBeanOld(e.code, e.name));
        }

        return data;
    }
}
